package com.xjtu.platform.user.student.firstVisit.dao;

import com.xjtu.platform.common.model.FirstVisit;
import com.xjtu.platform.common.model.User;
import com.xjtu.platform.user.consultor.visitRecord.VisitRecordDto;
import com.xjtu.platform.user.student.firstVisit.FirstVisitDto;
import com.xjtu.platform.user.student.firstVisit.SubmitOrderDto;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.ArrayList;
import java.util.List;

@Mapper
public interface FirstVisitDao {

    @Select(
            "select * from first_visit where student_id like #{student_id} " +
                    "and status like #{status} and type like #{type}"
    )
    List<FirstVisitDto> getInfo(FirstVisit dto);

    @Select(
            "select count(*) from first_visit where " +
                    "student_id = #{user_id} and  status != \"finish\" "
    )
    Integer checkIsInProgress(User dto);

    @Insert(
            "insert into first_visit(visit_id, student_id, expect_time, description, status, grade,type) " +
                    "values(#{visit_id},#{user_id},#{expect_time},#{description},#{type},#{grade},'')"
    )
    boolean insertNewFirstVisitOrder(SubmitOrderDto dto);

    @Select(
            "select max(visit_id)+1 from first_visit"
    )
    String getMaxIdPlus1();
    @Select(
            "select * from first_visit where student_id = #{userId}"
    )
    ArrayList<FirstVisit> searchAllFirstVisit(VisitRecordDto dto);
}
